﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ToolBox
{
    public partial class Entry : Form
    {
        public Entry()
        {
            InitializeComponent();
        }

        private void InitListView(ListView listview)
        {
            listview.BeginUpdate();
            listview.Columns.Add("名称", 95);
            listview.Columns.Add("描述",200);
            listview.GridLines = true;
            listview.FullRowSelect = true;
            listview.HideSelection = false;

            listview.LargeImageList = new ImageList();
            listview.LargeImageList.ImageSize = new Size(64, 64);
            listview.LargeImageList.ColorDepth = ColorDepth.Depth32Bit;
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\001.ico"));
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\002.ico"));
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\003.ico"));
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\004.ico"));
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\005.ico"));

            listview.SmallImageList = new ImageList();
            listview.SmallImageList.ImageSize = new Size(24, 24);
            listview.SmallImageList.ColorDepth = ColorDepth.Depth32Bit;
            listview.SmallImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\001.ico"));
            listview.SmallImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\002.ico"));
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\003.ico"));
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\004.ico"));
            listview.LargeImageList.Images.Add(Image.FromFile(Application.StartupPath + @"\icon\005.ico"));

            listview.Items.Add("ASCII", 0);
            listview.Items[0].SubItems.Add("ASCII转码工具");
            
            listview.Items.Add("进制转换", 1);
            listview.Items[1].SubItems.Add("二八十十六进制互转工具");
            listview.Items.Add("文件搜索", 2);
            listview.Items[2].SubItems.Add("文件与文件夹工具");
            listview.Items.Add("定时关机", 3);
            listview.Items[3].SubItems.Add("定时关机");
            listview.Items.Add("加解密", 4);
            listview.Items[3].SubItems.Add("文件夹/字符串加解密");


            listview.EndUpdate();


        }

        private void Entry_Load(object sender, EventArgs e)
        {
           // InitImageList();
            InitListView(exelist);
        }

        #region ToolStripMenuItem

        private void ToolStripMenuItem_ShowMain_Click(object sender, EventArgs e)
        {
            this.Visible = true;
            this.WindowState = FormWindowState.Normal;
            this.ToolStripMenuItem_ShowMain.Visible = false;
            this.ToolStripMenuItem_HideMain.Visible = true;
        }

        private void ToolStripMenuItem_HideMain_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            this.ToolStripMenuItem_ShowMain.Visible = true;
            this.ToolStripMenuItem_HideMain.Visible = false;
        }

        private void ToolStripMenuItem_LargeIcon_Click(object sender, EventArgs e)
        {
            this.exelist.View = View.LargeIcon;
        }

        private void ToolStripMenuItem_SmallIcon_Click(object sender, EventArgs e)
        {
            this.exelist.View = View.SmallIcon;
        }

        private void ToolStripMenuItem_List_Click(object sender, EventArgs e)
        {
            this.exelist.View = View.List;
        }

        private void ToolStripMenuItem_Title_Click(object sender, EventArgs e)
        {
            this.exelist.View = View.Tile;
        }

        private void ToolStripMenuItem_Details_Click(object sender, EventArgs e)
        {
            this.exelist.View = View.Details;
        }

        #endregion

        private void notifyIcon1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Point point = Control.MousePosition;
                this.contextMenuStrip1.Show(point);
            }
        }

        private void exelist_ItemActivate(object sender, EventArgs e)
        {
            switch (this.exelist.SelectedIndices[0])
            {
                case 0:
                    ASCII.Form1 Form0 = new ASCII.Form1();
                    Form0.ShowInTaskbar = false;
                    Form0.StartPosition = FormStartPosition.CenterParent;
                    Form0.ShowDialog();
                    break;
                case 1:
                    DigitTransform.Form1 Form1 = new DigitTransform.Form1();
                    Form1.ShowInTaskbar = false;
                    Form1.StartPosition = FormStartPosition.CenterParent;
                    Form1.ShowDialog();
                    break;
                case 2:
                    FileSeacher.Form1 Form2 = new FileSeacher.Form1();
                    Form2.ShowInTaskbar = false;
                    Form2.StartPosition = FormStartPosition.CenterParent;
                    Form2.ShowDialog();
                    break;
                case 3:
                    CloseWindow.Form1 Form3 = new CloseWindow.Form1();
                    Form3.ShowInTaskbar = false;
                    Form3.StartPosition = FormStartPosition.CenterParent;
                    Form3.ShowDialog();
                    break;
                case 4:
                    PassWord.Form1 Form4 = new PassWord.Form1();
                    Form4.ShowInTaskbar = false;
                    Form4.StartPosition = FormStartPosition.CenterParent;
                    Form4.ShowDialog();
                    break;
                default:
                    MessageBox.Show("请选择需要打开的工具");
                    break;
            }        
        }
    }
}
